#pragma once

#include <vulkan/vulkan.hpp>
#include "Render/ForegroundMesh/PreRenderForegroundMeshInstance.h"
#include "Math/Matrix4x4.h"
#include "Render/VulkanMemory/FixedUniformBuffer.h"

class CVulkanMesh;

class CVulkanForegroundMeshInstance
{
public:
    CVulkanForegroundMeshInstance();

    void BindData(const SPreRenderForegroundMeshInstance &InData);

    void RecordCommand(
        vk::CommandBuffer CommandBuffer
        , const SMatrix4x4 &InViewMatrix
        , const SMatrix4x4 &InProjectionMatrix
        ,vk::Extent2D InViewportSize
        );
protected:
    SVec3 Position;
    SQuat Rotation;
    SVec3 Scale;
    std::shared_ptr<CVulkanMesh> Mesh;
    SColor Color;
    SVec3 ViewPosition;

    struct SForegroundVertexModelUniform
    {
        float Model[16];
        float Color[4];
        float ViewPosition[3];
    };

    //模型矩阵缓冲
    std::shared_ptr<
        TVulkanUniformBuffer<SForegroundVertexModelUniform>
    > ModelUniformBuffer;
};


//绘制前景网格实例
class CVulkanForegroundMeshInstances
{
public:
    void PreProcess(const TVector<SPreRenderForegroundMeshInstance> &InDatas);

    void RecordCommand(
        vk::CommandBuffer CommandBuffer
        , const SMatrix4x4 &InViewMatrix
        , const SMatrix4x4 &InProjectionMatrix
        ,vk::Extent2D InViewportSize
        );
protected:
    TVector<CVulkanForegroundMeshInstance> Instances;

};